home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-11 | 8.1 KB | 436 lines | [TEXT/CWIE] |
- // CModelessRadios.cp -- dialog methods
-
- #include "CModelessRadios.h"
-
- #include <UEnvironment.h>
- #include <UReanimator.h>
- #include <URegistrar.h>
- #include <LStream.h>
- #include <LTabGroup.h>
- #include <LRadioGroupView.h>
- #include <LRadioButton.h>
- #include <LAMControlImp.h>
- #include <LGARadioButtonImp.h>
- #include <LTextGroupBox.h>
- #include <LAMControlViewImp.h>
- #include <LGATextGroupBoxImp.h>
- #include <CustomControls.h>
- #include <LBevelButton.h>
- #include <LAMBevelButtonImp.h>
- #include <LGABevelButtonImp.h>
- #include <LTextButton.h>
- #include <CTextUtils.h>
-
- #include "DModelessRadiosData.h"
- #include "EverythingCmds.h"
- #include <PP_Messages.h>
-
-
- #define PPob_ModelessRadiosID 216
- #define RidL_ModelessRadiosID 216
-
- Boolean CModelessRadios::sIsRegistered = false;
-
- //----------
- CModelessRadios* CModelessRadios::CreateModelessRadios (
- LCommander* inSuperCommander,
- CommandT inCommand,
- DModelessRadiosData* inData)
- {
- if (!sIsRegistered) {
- RegisterClass ();
- }
- CModelessRadios* dlog;
- dlog = ((CModelessRadios *)LWindow::CreateWindow(PPob_ModelessRadiosID, inSuperCommander));
- dlog->mCommand = inCommand;
- dlog->SetFromData (inData);
-
- return dlog;
- }
-
- //----------
- #define RegisterClasses(AbstractClass,AMImpClass,GAImpClass) \
- RegisterClass_(AbstractClass); \
- if (useAppearance) { \
- RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID); \
- } else { \
- RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID); \
- }
-
- //----------
- void CModelessRadios::RegisterClass ()
- {
- Boolean useAppearance = UEnvironment::HasFeature (env_HasAppearance);
-
- RegisterClass_(CModelessRadios);
-
- // register the pane classes we use
- RegisterClass_(LRadioGroupView);
- RegisterClasses (LRadioButton, LAMControlImp, LGARadioButtonImp);
- RegisterClasses (LTextGroupBox, LAMControlViewImp, LGATextGroupBoxImp);
- RegisterClasses (CRadioButton, CustomControlImp, CustomControlImp);
- RegisterClasses (LBevelButton, LAMBevelButtonImp, LGABevelButtonImp);
- RegisterClass_(LTextButton);
-
- sIsRegistered = true;
- }
-
- //----------
- CModelessRadios::CModelessRadios (
- LStream* inStream)
- : LGADialog (inStream)
- {
- mData = nil;
- }
-
- //----------
- CModelessRadios::~CModelessRadios()
- {
- delete mData;
- }
-
- //----------
- // This member function gets called once the containment hierarchy that contains
- // this pane has been built. It gives us a chance to get data members for
- // interesting subviews, and to do other operations now that our subviews exist.
- void CModelessRadios::FinishCreateSelf()
- {
- LGADialog::FinishCreateSelf();
-
- mRadioGroupGroup = (LRadioGroupView*) FindPaneByID ('Radp');
-
- mStandardRadio = (LRadioButton*) FindPaneByID ('Stad');
-
- mGroupGroup = (LRadioGroupView*) FindPaneByID ('Grop');
-
- mGraphicGroup = (LRadioGroupView*) FindPaneByID ('Grac');
-
- mStopRadio = (CRadioButton*) FindPaneByID ('Stop');
-
- mGoRadio = (CRadioButton*) FindPaneByID ('Go ');
-
- mBevelGroup = (LRadioGroupView*) FindPaneByID ('Bevl');
-
- mRadioButtonRadio = (LBevelButton*) FindPaneByID ('Radn');
-
- mRadioButton2Radio = (LBevelButton*) FindPaneByID ('Rad2');
-
- mTextGroup = (LRadioGroupView*) FindPaneByID ('Text');
-
- mNameRadio = (LTextButton*) FindPaneByID ('Name');
-
- mKindRadio = (LTextButton*) FindPaneByID ('Kind');
-
- mSizeRadio = (LTextButton*) FindPaneByID ('Size');
-
-
- UReanimator::LinkListenerToControls(this, this, RidL_ModelessRadiosID);
- // the purpose is to "connect" self to whatever controls
- // that we want to "listen" to
-
- // any additional initialization for your dialog:
-
- }
-
- //----------
- void CModelessRadios::SetFromData (
- DModelessRadiosData* inData)
- {
- mData = inData;
- mData->AddListener (this);
-
- mRadioGroupGroup->SetValue (mData->GetRadioGroup3 ());
- mGroupGroup->SetValue (mData->GetGroup3 ());
- mGraphicGroup->SetValue (mData->GetGraphic5 ());
- mBevelGroup->SetValue (mData->GetBevel3 ());
- mTextGroup->SetValue (mData->GetText3 ());
- }
-
- //----------
- DModelessRadiosData* CModelessRadios::GetData ()
- {
-
- return mData;
- }
-
- //----------
- void CModelessRadios::DataChanged (
- long inDataID)
- {
- StopListening ();
-
- if (inDataID == idRadioGroup3) {
- mRadioGroupGroup->SetValue (mData->GetRadioGroup3 ());
- }
- if (inDataID == idGroup3) {
- mGroupGroup->SetValue (mData->GetGroup3 ());
- }
- if (inDataID == idGraphic5) {
- mGraphicGroup->SetValue (mData->GetGraphic5 ());
- }
- if (inDataID == idBevel3) {
- mBevelGroup->SetValue (mData->GetBevel3 ());
- }
- if (inDataID == idText3) {
- mTextGroup->SetValue (mData->GetText3 ());
- }
-
- StartListening ();
- }
-
- //----------
- void CModelessRadios::ListenToMessage (
- MessageT inMessage,
- void *ioParam)
- {
- switch (inMessage) {
- case msg_OK:
- GetSuperCommander()->ProcessCommand(-mCommand, this);
- break;
-
- case msg_Cancel:
- DoClose();
- break;
-
- case msgDataChanged:
- DataChanged ((long)ioParam);
- break;
-
-
- default:
- ; // do something
- break;
- }
- }
-
- //----------
- Boolean CModelessRadios::ObeyCommand (
- CommandT inCommand,
- void* ioParam)
- {
- Boolean cmdHandled = true;
-
- if (inCommand < 0) {
- // modal dialog has finished
-
- switch (-inCommand) {
- }
-
- } else {
- switch (inCommand) {
-
- default:
- cmdHandled = LGADialog::ObeyCommand(inCommand, ioParam);
- break;
- }
- }
-
- return cmdHandled;
- }
-
- //----------
- void CModelessRadios::FindCommandStatus (
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- default:
- LGADialog::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
- // following functions will be obsoleted
- // retained only for backwards compatibility
- //----------
- Int32
- CModelessRadios::GetRadioGroupGroupChoice ()
- {
- return mRadioGroupGroup->GetCurrentRadioID ();
- }
-
- void
- CModelessRadios::SetRadioGroupGroupChoice (
- Int32 choice)
- {
- mRadioGroupGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Boolean
- CModelessRadios::GetStandardValue ()
- {
- return mStandardRadio->GetValue ();
- }
-
- void
- CModelessRadios::SetStandardValue (
- Boolean inValue)
- {
- mStandardRadio->SetValue (inValue);
- }
-
- //----------
- Int32
- CModelessRadios::GetGroupGroupChoice ()
- {
- return mGroupGroup->GetCurrentRadioID ();
- }
-
- void
- CModelessRadios::SetGroupGroupChoice (
- Int32 choice)
- {
- mGroupGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Int32
- CModelessRadios::GetGraphicGroupChoice ()
- {
- return mGraphicGroup->GetCurrentRadioID ();
- }
-
- void
- CModelessRadios::SetGraphicGroupChoice (
- Int32 choice)
- {
- mGraphicGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Boolean
- CModelessRadios::GetStopValue ()
- {
- return mStopRadio->GetValue ();
- }
-
- void
- CModelessRadios::SetStopValue (
- Boolean inValue)
- {
- mStopRadio->SetValue (inValue);
- }
-
- //----------
- Boolean
- CModelessRadios::GetGoValue ()
- {
- return mGoRadio->GetValue ();
- }
-
- void
- CModelessRadios::SetGoValue (
- Boolean inValue)
- {
- mGoRadio->SetValue (inValue);
- }
-
- //----------
- Int32
- CModelessRadios::GetBevelGroupChoice ()
- {
- return mBevelGroup->GetCurrentRadioID ();
- }
-
- void
- CModelessRadios::SetBevelGroupChoice (
- Int32 choice)
- {
- mBevelGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Boolean
- CModelessRadios::GetRadioButtonValue ()
- {
- return mRadioButtonRadio->GetValue ();
- }
-
- void
- CModelessRadios::SetRadioButtonValue (
- Boolean inValue)
- {
- mRadioButtonRadio->SetValue (inValue);
- }
-
- //----------
- Boolean
- CModelessRadios::GetRadioButton2Value ()
- {
- return mRadioButton2Radio->GetValue ();
- }
-
- void
- CModelessRadios::SetRadioButton2Value (
- Boolean inValue)
- {
- mRadioButton2Radio->SetValue (inValue);
- }
-
- //----------
- Int32
- CModelessRadios::GetTextGroupChoice ()
- {
- return mTextGroup->GetCurrentRadioID ();
- }
-
- void
- CModelessRadios::SetTextGroupChoice (
- Int32 choice)
- {
- mTextGroup->SetCurrentRadioID (choice);
- }
-
- //----------
- Boolean
- CModelessRadios::GetNameValue ()
- {
- return mNameRadio->GetValue ();
- }
-
- void
- CModelessRadios::SetNameValue (
- Boolean inValue)
- {
- mNameRadio->SetValue (inValue);
- }
-
- //----------
- Boolean
- CModelessRadios::GetKindValue ()
- {
- return mKindRadio->GetValue ();
- }
-
- void
- CModelessRadios::SetKindValue (
- Boolean inValue)
- {
- mKindRadio->SetValue (inValue);
- }
-
- //----------
- Boolean
- CModelessRadios::GetSizeValue ()
- {
- return mSizeRadio->GetValue ();
- }
-
- void
- CModelessRadios::SetSizeValue (
- Boolean inValue)
- {
- mSizeRadio->SetValue (inValue);
- }
-
-